<?php
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('kacamata' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;

$modulname = "Kesejahteraan _BN_ Fasilitas Kesehatan _BN_ Kacamata";
 
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case   "edit_kacamata_page" :
			end($_POST); $valid_post=key($_POST); 
			$validatepost = valid_kacamata($id);
			if($validatepost){
				$errors = message_multi_error($validatepost);
				$content = $errors;
				$content .= form_kacamata($id,$valid_post,false);
			}else{
				if($valid_post=="submit"){
					submit_kacamata($id);
					$content = 'Updated' ;
				}else{
					$content = form_kacamata($id,$valid_post,true);	
				}		
			}
			generate_my_web($content, $pagename ,"plain.php");
			exit;				
			break; 
	}
else: 	
	if($task == "edit_kacamata"){
		$title= ($id > '0' ) ?  "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=kacamata&task=edit_kacamata_page&id='.$id , $title , 300	); 
	}elseif($task == "edit_kacamata_page"){ 
		$content  = form_kacamata($id,'',false);
		generate_my_web($content,"","plain.php");
		exit; 
	}elseif($task == 'delete'){ 
		delete_kacamata($id);
		my_direct('index.php?com=kacamata');
	}else{
		$pagename = $modulname ; 
		load_facebox_script();
		$view =  list_kacamata(); 
	}
endif; 
generate_my_web($view, $pagename );
?>